Skip to content

Fix energy breakdown simulation by creating new integrator#29

Merged
delalamo merged 1 commit intomainfrom
claude/fix-integrator-context-warning-g6Xao
Jan 26, 2026
Merged

Fix energy breakdown simulation by creating new integrator#29
delalamo merged 1 commit intomainfrom
claude/fix-integrator-context-warning-g6Xao

Conversation

@delalamo
Copy link
Copy Markdown
Owner

Summary

Fixed a bug in get_energy_breakdown() where the simulation was being recreated with a stale integrator that was already bound to a previous context, causing errors.

Changes

  • Create a fresh LangevinIntegrator instance before recreating the simulation with force groups
  • Added explanatory comment clarifying why a new integrator is necessary

Details

When recreating a simulation with force groups enabled, OpenMM requires a new integrator instance because the previous integrator is already bound to the old simulation's context. Reusing the same integrator object would cause context binding conflicts. This fix ensures each simulation gets its own independent integrator.

Create a new LangevinIntegrator when recreating the simulation for force
group energy breakdown, since the original integrator is already bound
to the first simulation's context.
@delalamo delalamo merged commit bb8486b into main Jan 26, 2026
3 checks passed
@delalamo delalamo deleted the claude/fix-integrator-context-warning-g6Xao branch January 26, 2026 15:51
@delalamo delalamo mentioned this pull request Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants